package com.ytjj.qmyx.data.amqp.consumer;

import com.alibaba.druid.util.StringUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.rabbitmq.client.Channel;
import com.ytjj.common.constants.QueueConstants;
import com.ytjj.common.constants.SysConfigConstants;
import com.ytjj.common.dto.mqdto.SmsDto;
import com.ytjj.common.service.RedisService;
import com.ytjj.common.utils.Aes128CBCUtil;
import com.ytjj.common.utils.HttpClientUtil;
import com.ytjj.common.utils.feishu.FeiShuUtil;
import com.ytjj.qmyx.data.config.SanTongApiConfig;
import com.ytjj.qmyx.data.model.*;
import com.ytjj.qmyx.data.service.MsgService;
import com.ytjj.qmyx.data.service.OrdersService;
import com.ytjj.qmyx.data.util.EncryptUtil;
import com.ytjj.qmyx.data.util.SmsMengWangService;
import com.ytjj.qmyx.data.util.SmsWayUtil;
import com.ytjj.qmyx.mall.mapper.ExpressDicMapper;
import com.ytjj.qmyx.mall.model.ExpressDic;
import com.ytjj.qmyx.mall.model.Orders;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.util.*;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * amqp消息接收
 */
@Component
@Slf4j
@RefreshScope
public class CMPPMessageListener {
    @Resource
    private SanTongApiConfig sanTongApiConfig;
    @Autowired
    private RedisService redisService;
    @Autowired
    private MsgService msgService;
    @Resource
    private SmsMengWangService smsMengWangService;
    @Resource
    private ExpressDicMapper expressDicMapper;
    /**
     * 发送短信通道
     */
    @Value("${sms.channel:xinyichen}")
    private String sysChannel;

    /**
     * 后台短信功能的短信通道
     */
    @Value("${sms.adminChannel:xinyichen}")
    private String adminChannel;
    /**
     * XXXX优品签名的订单渠道
     */
    @Value("${txg.order.channel:ygyx-sms-71,ygyx-sms-71-old}")
    private String txgOrderChannel;
    /**
     * 订单支付成功短信内容
     */
    @Value("${shortSms.orderSucSms:您购买的%s下单成功，已为您加急发货。点击 %s 链接可自助查询订单或联系在线客服！}")
    private String orderSucSms;
    /**
     * 订单发货短信内容(商品名，快递信息，短链)
     */
    @Value("${shortSms.orderDeliverySms:您购买的%s已发货，%s点击 %s 可查询订单或联系客服！}")
    private String orderDeliverySms;
    /**
     * [mall.XXXX.com]短信连接：订单列表url
     */
    @Value("${shortSms.orderList.url:https://mall.XXXX.com/pages/order/orderlist.html}")
    private String mallOrderPage;

    /**
     * [vip.XXXX.com]短信连接：订单列表url
     */
    @Value("${shortSms.orderList.url:https://svip.XXXX.com/pages/order/orderlist.html}")
    private String otherOrderPage;

    /**
     * 短信连接：h5订单的单页面url
     */
    @Value("${shortSms.orderList.singlePageUrl:}")
    private String singlePageUrl;

    @Value("${sourcePlatform.secondDomain:ssvip,kq,vip,xvip,kvip}")
    private String secondDomain;

    /**
     * 手机号加密key
     */
    @Value("${shortSms.aesKey:eCcgc+=F'=M)$+'+}")
    private String aesKey;
    /**
     * 手机号加密IV
     */
    @Value("${shortSms.aesIV:g&_&J{~mK~e#h_Y2}")
    private String aesIV;
    /**
     * 短链域名
     * 存在多选的情况
     * 15：g3v.cn-XXXX优品,r4x.cn-果宝,z2m.cn-通用,
     */
    @Value("${shortSms.domain:15}")
    private String domain;

    @Value("${shortSms.key:}")
    private String key;

    @Value("${shortSms.url:}")
    private String url;

    @Value("${shortSms.sign:【闪购星】}")
    private String sign;

    @Value("${short.platform.source:3wt}")
    private String platformSource;

    @Resource
    private OrdersService ordersService;

    /**
     * 不用发送短信的类型
     */
    @Value("${shortSms.notSendSmsType:}")
    private String notSendSmsType;

    ThreadPoolExecutor pools = new ThreadPoolExecutor(10, 20, 5,TimeUnit.SECONDS, new LinkedBlockingQueue<>(1024 * 1024));


    @Transactional(rollbackFor = Exception.class)
    @RabbitListener(queuesToDeclare = @Queue(value = QueueConstants.SMS_QUEUE, durable = "true"))
    public void sellAfter(SmsDto smsDto, @Header(AmqpHeaders.DELIVERY_TAG) long deliveryTag, Channel channel) {
        log.info("\n\n收到一条消费后消息：" + smsDto + "\n\n");
        String[] phones = {smsDto.getPhone()};
        //短信签名
        String smsSign = sign;
        //短信渠道
        String smsChannel = sysChannel;
        String content = "";
        //redis的key
        String key = "";
        //当前只针对smsDto.getType 为2、6、7、9才有渠道标识,新增加类型需要修改下面一行代码
        String orderPage = spliceOrderPageUrl(smsDto.getDomainUrl(),otherOrderPage);
        if(StringUtils.isEmpty(orderPage)){
            FeiShuUtil.sendMsg(String.format("短信发送时，获取用户下单url出错！，手机号:%s",JSON.toJSONString(phones)));
        }
        //判断是否发送短信
        if (!StringUtils.isEmpty(notSendSmsType)) {
            List<String> strings = Arrays.asList(notSendSmsType.split(","));
            if (strings.contains(smsDto.getType().toString())) {
                return;
            }
        }
        log.info("=========当前短链通道======="+platformSource);
        if (1==smsDto.getType()) {
            content = "您的验证码：" + smsDto.getCode() + "，5分钟内有效，请注意账户安全。";
        }else if (2 == smsDto.getType()) {
            key = "ordercreate:sms:" + smsDto.getPhone() + "_" + smsDto.getOrderId();
            //替换占位符,原商品名称smsDto.getCode()，需求要求商品名改成<宝贝>
            content = "亲爱的顾客，您订购的商品已下单成功！我们会尽快为您安排发货，物流信息将实时更新。您可在 “我的订单” 中查看详情，感谢您的信任";
            log.info("====new sms content by order is pay success==={}", content);
        }else if (6 == smsDto.getType()) {
            key = "express:sms:" + smsDto.getPhone() + "_" + smsDto.getExpressNo();
            content = String.format("亲爱的顾客，您的宝贝已发货，%s",smsDto.getExpressNo());
            log.info("====new sms content by order delivery==={}", content);
        }
// --- began---注释短信中包含短链
//        else if (2 == smsDto.getType()) {
//            key = "ordercreate:sms:" + smsDto.getPhone() + "_" + smsDto.getOrderId();
//            //短信长链
//            String smsUrl_long = msgService.generateLongUrl(orderPage, smsDto.getPhone(), smsDto.getOrderSource(),smsDto.getToken(),smsDto.getChannel());
//            //生成短链
//            String smsUrl_short = "";
//            if(SysConfigConstants.SAN_WEI_TUI.equals(platformSource)){
//                log.info("=========当前短链通道 3wt=======");
//                smsUrl_short = msgService.generaterShortUrl(Arrays.asList(smsUrl_long));
//            }else if(SysConfigConstants.SHORT_CHAIN.equals(platformSource)){
//                log.info("=========当前短链通道 short_chain=======");
//                smsUrl_short = msgService.longToShortUrl(smsUrl_long);
//            }
//            //替换占位符,原商品名称smsDto.getCode()，需求要求商品名改成<宝贝>
//            content = String.format(orderSucSms, "宝贝", smsUrl_short);
//            log.info("====new sms content by order is pay success==={}", content);
//        }else if (6 == smsDto.getType()) {
//            key = "express:sms:" + smsDto.getPhone() + "_" + smsDto.getExpressNo();
//            //短信长链
//            String smsUrl_long = msgService.generateLongUrl(orderPage, smsDto.getPhone(), smsDto.getOrderSource(),smsDto.getToken(),smsDto.getChannel());
//            //生成短链
//            String smsUrl_short = "";
//            if(SysConfigConstants.SAN_WEI_TUI.equals(platformSource)){
//                smsUrl_short = msgService.generaterShortUrl(Arrays.asList(smsUrl_long));
//            }else if(SysConfigConstants.SHORT_CHAIN.equals(platformSource)){
//                smsUrl_short = msgService.longToShortUrl(smsUrl_long);
//            }
//            //快递信息
//            String expressInfo = "";
//            //快递信息
//            if(!StringUtils.isEmpty(smsDto.getExpressNo()) && !StringUtils.isEmpty(smsDto.getExpressName())){
//                expressInfo = smsDto.getExpressName()+smsDto.getExpressNo()+"，";
//            }
//            //替换占位符,原商品名称smsDto.getCode()，新需求要求商品名改成<宝贝>
//            content = String.format(orderDeliverySms, "宝贝",expressInfo, smsUrl_short);
//            log.info("====new sms content by order delivery==={}", content);
//        }
//--- end---

        else if (7 == smsDto.getType()){
            smsChannel = adminChannel;
            smsSign = smsDto.getChannel();
            content = smsDto.getCode();
        }else if (8 == smsDto.getType()){
            smsChannel = adminChannel;
            smsSign = smsDto.getChannel();
            content = smsDto.getCode();
        }else if (9 == smsDto.getType()){
            smsChannel = adminChannel;
            Orders orders = ordersService.findOrderByChildOrderNo(smsDto.getChildOrderNo());
            smsDto.setDomainUrl(orders.getDomainUrl());
            orderPage = spliceOrderPageUrl(smsDto.getDomainUrl(),otherOrderPage);
            log.info("orderPage===:{}",orders.getDomainUrl());
            String smsUrl_long = msgService.generateLongUrl(orderPage, orders.getTel(), orders.getOrderSource(),orders.getH5Token(),orders.getChannel());
            //生成短链
            String smsUrl_short = "";
            if(SysConfigConstants.SAN_WEI_TUI.equals(platformSource)){
                smsUrl_short = msgService.generaterShortUrl(Arrays.asList(smsUrl_long));
            }else if(SysConfigConstants.SHORT_CHAIN.equals(platformSource)){
                smsUrl_short = msgService.longToShortUrl(smsUrl_long);
            }
            content = String.format(smsDto.getCode(),smsUrl_short);
        } else if (10 == smsDto.getType()){
            content = smsDto.getCode();
        } else if (11 == smsDto.getType()) {
            content = smsDto.getCode();
        } else if (12 == smsDto.getType()) {
            Orders orders = ordersService.findOrderByChildOrderNo(smsDto.getChildOrderNo());
            smsDto.setDomainUrl(orders.getDomainUrl());
            orderPage = spliceOrderPageUrl(smsDto.getDomainUrl(),otherOrderPage);
            String smsUrl_long = msgService.generateLongUrl(orderPage, orders.getTel(), orders.getOrderSource(),orders.getH5Token(),orders.getChannel());
            //生成短链
            String smsUrl_short = "";
            if(SysConfigConstants.SAN_WEI_TUI.equals(platformSource)){
                smsUrl_short = msgService.generaterShortUrl(Arrays.asList(smsUrl_long));
            }else if(SysConfigConstants.SHORT_CHAIN.equals(platformSource)){
                smsUrl_short = msgService.longToShortUrl(smsUrl_long);
            }
            content = String.format(smsDto.getCode(),smsUrl_short);
        } else {
            return;
        }
        try {
            if (!StringUtils.isEmpty(key)) {
                String sendFlag = redisService.get(key);
                if ("1".equals(sendFlag)) {
                    return;
                }
            }
        } catch (Exception e) {
            log.error("===获取redis中发送短信标志异常==={}{}", key, e);
        }
        //redis中发送短信已发送标志
        if (!StringUtils.isEmpty(key)) {
            redisService.set(key, "1");
            redisService.expire(key, 2 * 24 * 60 * 60);
        }

        log.info("===content==={}", smsSign+content);
        //短信api返回结果
        String result_sto = "";
        if ("santong".equals(smsChannel)) {
            try {
                result_sto = EncryptUtil.sendSanTong(sanTongApiConfig.getUrl(), sanTongApiConfig.getAccount(), sanTongApiConfig.getPassword(), phones, content, smsSign);
            } catch (Exception e) {
                log.error("=======调用santong短信渠道出错！=======",e);
            }
        } else if ("xinyichen".equals(smsChannel)) {
            try {
                JSONObject jsonObject = SmsWayUtil.sendSmsWithResult(smsDto.getPhone(), smsSign + content);
                if (null != jsonObject) {
                    result_sto = jsonObject.toString();
                }
            } catch (Exception e) {
                log.error("=======调用xinyichen短信渠道出错！=======",e);
            }
        }else if("mengwang".equals(smsChannel)){
            result_sto = smsMengWangService.sendSmsWithResult(smsDto.getPhone(), content, smsSign);
        }

        if (StringUtils.isEmpty(result_sto)) {
            log.info("===大汉三通 or 欣易辰发送失败，返回结果为空===");
            FeiShuUtil.sendMsg(String.format("===大汉三通 or 欣易辰发送失败，返回结果为空 phone:%s; content:%s===", smsDto.getPhone(), smsSign + content));
            return;
        } else {
            if ("santong".equals(smsChannel)) {
                SanTongResponse response = JSONObject.parseObject(result_sto, SanTongResponse.class);
                log.info("===santong response==={}", response);
                if (!"0".equals(response.getResult())) {
                    FeiShuUtil.sendMsg(String.format("===大汉三通发送失败===phone:%s-->content:%s；response:%s ===", smsDto.getPhone(), smsSign + content, JSON.toJSON(response)));
                    log.info("===大汉三通发送失败==={}", response.getDesc());
                }
            } else if ("xinyichen".equals(smsChannel)) {
                XinycSmsResponse response = JSONObject.parseObject(result_sto, XinycSmsResponse.class);
                log.info("===xinyichen response==={}", response);
                if (0 != response.getStatus()) {
                    FeiShuUtil.sendMsg(String.format("===欣易辰发送失败===phone:%s-->content:%s；response:%s ===", smsDto.getPhone(), smsSign + content, JSON.toJSON(response)));
                    log.info("===欣易辰发送失败==={}", response.getMessage());
                }
            }else if ("mengwang".equals(smsChannel)){
                MengWangResponse mengWangResponse = JSONObject.parseObject(result_sto, MengWangResponse.class);
                log.info("===mengwang response==={}", mengWangResponse);
                if (!"0".equals(mengWangResponse.getResult())) {
                    FeiShuUtil.sendMsg(String.format("===梦网发送失败===phone:%s-->content:%s；response:%s ===", smsDto.getPhone(), smsSign + content, JSON.toJSON(mengWangResponse)));
                    log.info("===梦网发送失败==={}", mengWangResponse.getDesc());
                }
            }
        }
        //记录发送短信
        String finalResult_sto = result_sto;
        String finalContent = content;
        String finalSmsSign = smsSign;
        String finalSmsChannel = smsChannel;
        pools.execute(() -> {
            msgService.saveMsgFailLog(finalResult_sto, finalSmsChannel,smsDto.getType().byteValue(),smsDto.getPhone(), finalContent, finalSmsSign,smsDto.getOrderId());
        });
    }


    public static void main2(String[] args) {
        String longUrl = "https://xvip.XXXX.com/pages/order/orderlist.html";
        String key = "eCcgc+=F'=M)$+'+";
        String iv = "g&_&J{~mK~e#h_Y2";
        String md5_phone = null;
        try {
            md5_phone = Aes128CBCUtil.encrypt("13207940511", key, iv);
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (!longUrl.contains("?")) {
            longUrl = longUrl + "?serialNumber=";
        } else {
            longUrl = longUrl + "&serialNumber=";
        }
        md5_phone = md5_phone.replaceAll("\\+", "%2B");
        md5_phone = md5_phone.replaceAll("=", "%3D");
        md5_phone = md5_phone.replaceAll("/", "%2F");
        longUrl = longUrl + md5_phone;
        if (!StringUtils.isEmpty("h5")) {
            longUrl = longUrl + "&orderSource=h5";
        }
//        System.out.println(generaterShortUrl(Arrays.asList(longUrl)));
    }

    /**
     * 生成并返回短链内容
     * @param handleLongUrls 需要转短链的长链接集合
     * @return
     */
    private String generaterShortUrl2(List<String> handleLongUrls) {
        long curTimeMillis = System.currentTimeMillis();
        System.out.println("====短链接口开始====" + curTimeMillis);
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("urlArr", handleLongUrls);
        map.put("format", "json");
        map.put("domain", domain);
        map.put("key", "6190c40b60f59d377d3b119566@9ce82b9d1ead5548a63205b58fd804e6");
        String result = HttpClientUtil.doPostJson("http://create.3wt.cn/batchCreate/tinyUrl", JSONObject.toJSONString(map));
        ShortUrlBatchResponse response = JSONObject.parseObject(result, ShortUrlBatchResponse.class);

        if (null == response) {
            log.info("===批量生成短链失败====返回对象为空了====");
            return null;
        }
        ShortUrlCommonResponse meta = response.getMeta();
        if (!"200".equals(meta.getCode())) {
            log.info("====批量生成短链失败===code:{},msg:{}", meta.getCode(), meta.getMsg());
            return null;
        }
        List<Map<String, String>> data = response.getData();
        if (CollectionUtils.isEmpty(data)) {
            log.info("===批量生成短链返回data为空了=====");
            return null;
        }
        Map<String, String> dataMap = data.get(0);
        Collection<String> values = dataMap.values();
        AtomicReference<String> shortUrl = new AtomicReference<>("");
        values.stream().forEach(value -> {
            shortUrl.set(value);
        });
        if (!org.springframework.util.StringUtils.isEmpty(shortUrl.get())) {
            shortUrl.set(shortUrl.get().replace("http://",""));;
            shortUrl.set(shortUrl.get().replace("https://", ""));
        }
        return shortUrl.get();
    }


    /**
     * 获取用户下单域名的订单url
     * @param domainUrl 下单域名 如：https://mall.XXXX.com
     * @param configPath 配置的订单页面路径 如：/pages/order/orderlist.html 或者 https://svip.XXXX.com/pages/order/orderlist.html
     * @return String
     */
    public String spliceOrderPageUrl(String domainUrl,String configPath){
        //订单页面路劲
        String orderPageUrl = "";
        try {
            //正则匹配： https://mall.XXXX.com/
            Pattern pattern = Pattern.compile("[a-zA-z]+://(.*?)/");
            Matcher sufUrlMatch = pattern.matcher(configPath);
            //如果下单域名不存在，则使用配置的路径
            if(StringUtils.isEmpty(domainUrl)){
                orderPageUrl = singlePageUrl;
//                //如果配置路径完整则使用默认配置的路径
//                if(sufUrlMatch.find()){
//                    orderPageUrl = configPath;
//                }
            }else {
                //如果配置路径完整,则截取后段。如： /pages/order/orderlist.html
                if(sufUrlMatch.find()){
                    String group2 = sufUrlMatch.group();
                    String[] split = configPath.split(group2);
                    orderPageUrl = domainUrl+"/"+split[1];
                }else {
                    orderPageUrl = domainUrl+configPath;
                }
            }
        } catch (Exception e) {
            log.error("获取订单地址出错！{}",e);
        }
        log.info(String.format("==========>当前订单下单域名：%s  配置的路径：%s   短信url：%s",domainUrl,configPath,orderPageUrl));
        return orderPageUrl;
    }

    public static void main(String[] args) {
        String channelUrl = "https://mall.XXXX.com";
//        String orderUrl = "https://svip.XXXX.com/pages/order/orderlist.html";
        String orderUrl = "/pages/order/orderlist.html";
//
////        System.out.println(spliceOrderPageUrl("",channelUrl,configUrl));
//        String s = spliceOrderPageUrl(channelUrl, orderUrl);
//        System.out.println("========>"+s);

    }

    public void main2() {
        String account = "xxxx";
        String password = "xxxxx";
        String[] phones = {"13786028713"};

        String message = "尊敬的客户，您购买的【凉感丝滑】日系水洗天丝等下单成功，正在为您加急打包发货中，请您耐心等待。点击下方链接可自助查询订单或联系在线客服 z2m.cn/18Bznh ，祝您购物愉快！";
//        message = String.format(message, "智能扫地机", "z2m.cn/1nD8vz");
//        message = "尊敬的客户您好！您申请的退货退款申请已通过，请在今明两天内按照提供的售后地址把商品寄回，如超过退货期限将无法做退货退款处理；寄回后请及时上传运单号，或者告知人工客服寄回单号（温馨提示：请保持原包装寄回，不影响第二次销售。如仓库收到商品有影响二次销售的痕迹将会把商品退回，请您知悉！）";
        message = "尊敬的客户您好";
        String result = EncryptUtil.sendSanTong("http://www.dh3t.com/json/sms/Submit", account, password, phones, message, "【XXXX优品】");
        System.out.println(result);

//
//        String key = "eCcgc+=F'=M)$+'+";
//        String iv = "g&_&J{~mK~e#h_Y2";
//        String md5_phone = null;
//        String orderSource = "weapp";
//        try {
//            md5_phone = Aes128CBCUtil.encrypt("18873058010", key, iv);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        if (org.springframework.util.StringUtils.isEmpty(md5_phone)) {
//            System.out.println("md5_phone is null");
//        }
//        String longUrl = "https://xvip..com/pages/order/orderlist.html";
//        if (!longUrl.contains("?")) {
//            longUrl = longUrl + "?serialNumber=";
//        }else {
//            longUrl = longUrl + "&serialNumber=";
//        }
//        md5_phone = md5_phone.replaceAll("\\+", "%2B");
//        md5_phone = md5_phone.replaceAll("=", "%3D");
//        md5_phone = md5_phone.replaceAll("/", "%2F");
//        longUrl = longUrl + md5_phone;
//        if (!StringUtils.isEmpty(orderSource)) {
//            longUrl = longUrl + "&orderSource=" + orderSource;
//        }
//        System.out.println(longUrl);
//
//        // https://xvip..com/pages/order/orderlist.html?serialNumber=Kk0VWKmBYakWVw9U6hNn%2Fw%3D%3D&orderSource=h5
//
//        long curTimeMillis = System.currentTimeMillis();
//        System.out.println("====短链接口开始====" + curTimeMillis);
//        Map<String, Object> map = new HashMap<String, Object>();
//        map.put("urlArr", Arrays.asList(longUrl));
//        map.put("format", "json");
//        map.put("domain", "z2m.cn");
//        map.put("key", "6190c40b60f59d377d3b119566@9ce82b9d1ead5548a63205b58fd804e6");
//        String result = HttpClientUtil.doPostJson("http://create.3wt.cn/batchCreate/tinyUrl", JSONObject.toJSONString(map));
//        ShortUrlBatchResponse response = JSONObject.parseObject(result, ShortUrlBatchResponse.class);
//
//        if (null == response) {
//            log.info("===批量生成短链失败====返回对象为空了====");
//            return;
//        }
//        ShortUrlCommonResponse meta = response.getMeta();
//        if (!"200".equals(meta.getCode())) {
//            log.info("====批量生成短链失败===code:{},msg:{}", meta.getCode(), meta.getMsg());
//            return;
//        }
//        List<Map<String, String>> data = response.getData();
//        if (CollectionUtils.isEmpty(data)) {
//            log.info("===批量生成短链返回data为空了=====");
//            return;
//        }
//        Map<String, String> dataMap = data.get(0);
//        Collection<String> values = dataMap.values();
//        AtomicReference<String> shortUrl = new AtomicReference<>("");
//        values.stream().forEach(value -> {
//            shortUrl.set(value);
//        });
//        if (!org.springframework.util.StringUtils.isEmpty(shortUrl.get())) {
//            shortUrl.set(shortUrl.get().replace("http://",""));;
//            shortUrl.set(shortUrl.get().replace("https://", ""));
//        }
//        System.out.println(shortUrl.get());
    }
}
